"""
线索页面
"""

from selenium.webdriver.common.by import By
from page.base_page import BasePage


class CluePage(BasePage):
    url = "/crm/index.php?m=leads"
    # 新建线索定位器
    add_clue_locator = (By.LINK_TEXT, '新建线索')

    # 获取当前页面地址
    def get_current_url(self):
        return self.driver.current_url

    # 点击新建线索
    def add_clue(self):
        self.driver.find_element(*self.add_clue_locator).click()

    # 获取线索页面的文本
    def row_cell_get_table_text_a_span(self,table_loc,row,cell):
        cell = str(cell)
        row = str(row)
        locator = table_loc[1] + '/tbody/tr[' + row + ']/td[' + cell +']' + '/a/span'
        text = self.driver.find_element(By.XPATH,locator).text
        return text

    # 获取线索页面的文本
    def row_cell_get_table_text(self,table_loc,row,cell):
        cell = str(cell)
        row = str(row)
        locator = table_loc[1] + '/tbody/tr[' + row + ']/td[' + cell +']' + '/a'
        text = self.driver.find_element(By.XPATH,locator).text
        return text

    # 获取线索页面的文本
    def row_cell_get_table_text_span(self,table_loc,row,cell):
        cell = str(cell)
        row = str(row)
        locator = table_loc[1] + '/tbody/tr[' + row + ']/td[' + cell +']' + '/span'
        text = self.driver.find_element(By.XPATH,locator).text
        return text

